#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "user.h"
#include "room.h"
#include "bill.h"


int managerMenu()
{
	int c;
	showTime(1);
	printf("\t\t\t        旅店管理系統\n");
	printf("\t\t\t=============================\n");
	printf("\t\t\t      旅店经理 管理系统\n");
	printf("\t\t\t   * 1 浏览用户\n");
	printf("\t\t\t   * 2 增加用户\n");
	printf("\t\t\t   * 3 删除用户\n");
	printf("\t\t\t   * 4 浏览客房\n");
	printf("\t\t\t   * 5 修改客房\n");
	printf("\t\t\t   * 6 增加客房\n");
	printf("\t\t\t   * 7 删除客房\n");
	printf("\t\t\t   * 8 查看收支\n");
	printf("\t\t\t   * 0 注销\n");
	printf("\t\t\t=============================\n");
	printf("\t\t\t请选择:");
	scanf("%d",&c);
	getchar();
	while(c < 0||c > 8)
	{
		printf("请重新输入:");
		scanf("%d",&c);
		getchar();
	}
	return c ;


}


void managerSystem(User *r)
{
	int c,c8,loop = 1;
	User *ru;
	Room *ro;
	bill *rb;
	while(loop)
	{
		system("clear");
		//printf("\n%s",r->name);
		//showTime(1);
		c = managerMenu();
		switch(c)
		{
			case 1:
				printf(RED);
				printf("show users\n");
				printf(NONE);
				ru = read_user();
				display_user(ru);
				printf("输入任意指令以继续:\n");
				getchar();
				break;
			case 2:
				printf(RED);
				printf("add user\n");
				printf(NONE);
				add_user();
				break;
			case 3:
				printf(RED);
				printf("remove user\n");
				printf(NONE);
				remove_user();
				break;
			case 4:
				printf(RED);
				printf("show room\n");
				printf(NONE);
				ro = read_room();
				display_room(ro);
				printf("输入任意指令以继续:\n");
				getchar();				
				break;
			case 5:
				printf(RED);
				printf("change room\n");
				printf(NONE);
				change_room();				
				break;
			case 6:
				printf(RED);
				printf("add room\n");
				printf(NONE);
				add_room();
				break;
			case 7:
				printf(RED);
				printf("remove room\n");
				printf(NONE);
				remove_room();
				break;
			case 8:
				printf(RED);
				printf("check Bill\n");
				printf(NONE);
				printf("请选择:\n");
				printf("1.按房间号查询 2.按开房时间查询 3.查看全部 0.退出\n");
				scanf("%d",&c8);
				getchar();
				switch(c8)
				{
					case 1 :
						find_bill_roomId();
						break;
					case 2 :
						find_bill_inDay();
						break;
					case 3 :
						rb = read_bill();
						display_bill(rb);
						break;
					case 4 :
						break;
					case 5 :
					default:
						break;
				}
				printf("输入任意指令以继续:\n");
				getchar();
				break;
			case 0:
			default:
				loop = 0;
				break;
		}//switch(c)
	}
}
